//
// Created by Administrator on 2021/9/16.
//

#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include "task1.h"
void initRandSeed(){
    srand(time(NULL));
}

int getRandNum(){
    return (rand()%(MAX_NUM - MIN_NUM + 1)) + MIN_NUM;
}

char getRandOp(){
    char op[] = {'+','-','*','/'};
    return op[getRandNum()%4];
}

void task1(){
    initRandSeed();
    while(true) {
        int num1 = getRandNum();
        char op = getRandOp();
        int num2 = getRandNum();
        int answer = 0;
        switch (op) {
            case '+': {
                answer = num1 + num2;
                break;
            }
            case '-': {
                answer = num1 - num2;
                break;
            }
            case '*': {
                answer = num1 * num2;
                break;
            }
            case '/': {
                answer = num1 / num2;
                break;
            }
        }

        printf("%d %c %d = ?", num1, op, num2);
        int stu_answer;
        do {
            scanf("%d", &stu_answer);
            if (stu_answer == answer) {
                printf("Right!\n");
                break;
            } else {
                printf("Wrong! Try again!\n");
            }
        } while (true);
    }
}